package com.qfjy.student.zhangqingqqing.sort;

/**
 * @Author zhangqingqing
 * @Date 2021/6/23 20:57
 */

public class SelectSort {
    public static void main(String[] args) {
        int[] arr={9,21,34,1,17};
        int length = arr.length;
        int temp = 0;
        int minIndex;
        for (int j = 0; j <length- 1;j++) {
            minIndex = j;
            for (int i = j; i < length- 1; i++) {
                if (arr[minIndex] > arr[i + 1]) {
                    minIndex = i+1;
                }
            }
            temp = arr[minIndex];
            arr[minIndex]= arr[j];
            arr[j]=temp;
        }
        for (int i : arr) {
            System.out.print(i + " ");
        }
    }
}
